const AblumsControl = require("../control/AlbumsControl")
const express = require("express")
const router = express.Router()
const multer = require("multer")
const path = require("path")
const storage = multer.diskStorage({
    //自定义存储位置
    destination: function (req, res, cb) {
        cb(null, 'public/images/albums')
    },
    //文件名字
    filename: function (req, file, cb) {
        const uniquFilename = Date.now() + '-' + Math.round(Math.random() * 1E9)
        //获取后缀
        const ext = path.extname(file.originalname)
        cb(null, uniquFilename + ext)
    }
})
const upload_albums = multer({ storage: storage })
// upload_music.single("file")


router.post('/many', upload_albums.array("files", 100), AblumsControl.img_many)
router.get('/:year/:month/:id', AblumsControl.find_imgs)
router.delete('/:year/:month/:day', AblumsControl.dele_img)
module.exports = router





module.exports = router